{layout name="layout" /}


<div  style="float:right;">
	<a href="{:url('admin/Index/index')}">登录</a>
	<a href="{:url('admin/Index/register')}">注册</a>
</div>
<br />
<div>
	<form action= "{:url('admin/AdminUser/addUser')}" method="post" onsubmit="return validate()">
	账&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号：<input type="text" name="userName" onblur="validateUserName('{:url('admin/AdminUser/validateUserName')}')">  
	<span></span>	
	<br />
	密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码：<input type="text" name="userPassword" value="">	
	<br />
	重复密码：<input type="text" name="userPasswordTwo" value="">	
	<br />
	验 证 码：<input type="test" name="validateCode" value="">		
	<div>{:captcha_img()}</div>
	<br />
	<input id='register'  type="submit" value="注册" class="widthly" >
	</form>
</div>

{literal}
<script>
	var validateName = false;
	function validate()
	{
		if(trim($("input[name='userPassword']").val()) != trim($("input[name='userPasswordTwo']").val()))
		{
			console.log($("input[name='userPassword']").val());
			console.log('俩次密码不一样');
			console.log($("input[name='userPasswordTwo']").val());
			return false;
		}
		return validateName;
	}

	function validateUserName(url)	
	{
		$.ajax({
			url : url,
			type : 'post',
			dataType : 'json',
			timeout : 3000,
			data : {
				userName : $("input[name='userName']").val()
			},
			success : function(result){
				console.log(result);
				validateName = result['result'];
				$('span').html(result['message']);
			},
			error : function (result){
				$('span').html('该用户名已经存在');
			}
		});
	}
</script>
{/literal}


